package com.rd.student.jiaji.class1.jinhongyu.day0801;

public class WuZiQi {
    private int[][] chessboard;
    private int palyer;

    public WuZiQi() {
        this.chessboard = new int[15][15];
        this.palyer = 1;
    }

    public boolean move(int x, int y) {
        if (this.chessboard[x][y] != 0) {
            return false;
        }
        this.chessboard[x][y] = this.palyer;
        this.palyer = 3 - this.palyer;//玩家轮换操作
        return true;
    }

    public void display() {
        for (int[] row : this.chessboard) {
            for (int cell : row) {
                if (cell == 1){
                    System.out.print("O");
                }else if (cell ==2){
                    System.out.print("X");
                }else {
                    System.out.print(".");
                }
                System.out.print(" ");
            }
            System.out.println();
        }
    }
}
